<?php

class Core_ModuleControllerPlugin extends Zend_Controller_Plugin_Abstract {

  public function preDispatch(Zend_Controller_Request_Abstract $request) {

    $layout = Zend_Layout::getMvcInstance();
    $dir = Zend_Controller_Front::getInstance()->getModuleDirectory();
    if (file_exists($dir . DIRECTORY_SEPARATOR . 'layouts/scripts/layout.phtml')) {
      $layout->setLayoutPath($dir . DIRECTORY_SEPARATOR . '/layouts/scripts/');
    } else {
      $layout->setLayout("default");
    }
  }

}

?>
